﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head class="am-topbar am-topbar-inverse admin-header">
<jsp:include page="/commonPages/admin-meta.jsp" flush="true" />
<!-- CSS files -->
<jsp:include page="/commonPages/admin-style.jsp" flush="true" />

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户管理</title>
<script src="<%=request.getContextPath()%>/js/jquery.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/page.js"></script>

<script src="<%=request.getContextPath()%>/js/bootstrap.min.js"></script>
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/assets/css/amazeui.min.css" />
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/assets/css/admin.css">
</head>
<script type="text/javascript">

	function addUser(){
	
	
		var lastName =  document.getElementById("userName").value;
		var  passwd= document.getElementById("password").value;
		var group = document.getElementById("group");
		var groupName = group.options[group.selectedIndex].text;
		var groupId = group.options[group.selectedIndex].value;

		alert(passwd);
		
		$.ajax({
			contentType :"application/x-www-form-urlencoded;charset=utf-8",
            url : "user/addUser",
            type : "post",
            data : {
            	lastName : lastName,
            	passwd : passwd,
            	groupName : groupName,
            	groupId : groupId,
            },
		    success : function(data) {
            	if(data == "material")
            		window.location.href = "getMaterial.jsp";
            }
     });
		
		
	}
</script>
<body  onLoad="goPage(1,10);">


	<div id="wrapper">

		<!-- Navigation -->
		<jsp:include page="/commonPages/admin-navigator.jsp" flush="true" />

		<!-- Page Content -->
		<div id="page-wrapper">
		
		
		<div class="modal-body">
				<div class="row">
					<form id="formInput" class="form-horizontal" role="form">
						<div class="tabbable" id="tabs-437698">
							<ul class="nav nav-tabs">
							
							<li class="active"><a href="#panel-636968"
									data-toggle="tab" class="size" style="color: black">用户列表</a></li>
							
								<li ><a href="#panel-636967"
									data-toggle="tab" class="size" style="color: black">添加用户</a></li>
								
								
							</ul>
							<div class="tab-content">
								<div class="tab-pane " id="panel-636967">
									<div class="am-cf admin-main">
										<div class="admin-content">
											<div class="am-g">
												<div class="am-u-sm-12">
													<table class="tableHue2" width="100%" border="1" bordercolor="#dddddd" cellspacing="0" cellpadding="0">
                      <tbody>
                        <tr>
                          <td width="15%" class="title1" >用户名称：</td>
                          <td class="left"><input name="lastName" type="text" class="input_text2" size="30" id = "userName"/></td>
                        </tr>
                        <tr>
                          <td width="15%" class="title1" >密码：</td>
                          <td class="left"><input name="passwd" type="text" class="input_text2" size="30" id = "password"/></td>
                        </tr>
                        <tr>
                          <td width="15%" class="title1" >用户组：</td>
                          <td class="left">
							<select name="groupId" id="group">
								<c:forEach var="group" items="${groups}">
									<option value="${group.id}" >${group.name}</option>
								</c:forEach>
							</select>
						  </td>
                        </tr>
                      
                      </tbody>
                  </table>
                    <div class="fun_area" style="text-align:center;"><input type="submit" value="确 定" class="input_button1" onclick="addUser()"/></div>
												</div>
											</div>
										</div>
									</div>
								</div>
								
								<div class="tab-pane active" id="panel-636968">
									<div class="am-cf admin-main">
  <div class="admin-content">
      <div class="am-g">
        <div class="am-u-sm-12">
            <table class="am-table am-table-striped am-table-hover table-main" id="mytable">
              <thead id="tb_head">
	                <tr>
                  <td width="30%"><strong>姓名</strong></td>
                  <td width="10%"><strong>用户密码</strong></td>
                  <td width="50%"><strong>所属用户组</strong></td>
                  <td width="10%"><strong>操作</strong></td>
                </tr>
	              </thead>
              <tbody>
              <c:forEach var="user" items="${users}">
                <tr>
                  <td>${user.lastName}</td>
                  <td>${user.passwd}</td>
                  <td>${user.groupName}</td>
                  <td><a href="user/deleteUser?userId=${user.userId}">删除</a></td>
                </tr>
              </c:forEach>
              </tbody>
            </table>
           <table width="60%" align="right" margin-top="0">
        	<tr><td><div id="barcon"></div></td></tr>
    	   </table>
            <hr />
        </div>

      </div>
    </div>

  </div>
								</div>
								
							</div>
						</div>
					</form>
				</div>
			</div>
		
		
		

	
      </div>

	<jsp:include page="/commonPages/admin-script.jsp" flush="true" />

</div>
    
</body>



</html>
